package com.esri.core.tasks.geodatabase;

import com.esri.core.internal.util.d;
import io.reactivex.annotations.SchedulerSupport;
import java.io.IOException;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class LayerQuery {
    private boolean _includeRelated;
    private int _layerId;
    private QueryOption _queryOption;
    private boolean _useGeometry;
    private String _where;

    /* loaded from: classes.dex */
    private enum QueryOption {
        USE_FILTER("useFilter"),
        NONE(SchedulerSupport.NONE),
        ALL("all");
        
        private String _value;

        QueryOption(String str) {
            this._value = str;
        }

        public String getValue() {
            return this._value;
        }

        @Override // java.lang.Enum
        public String toString() {
            return this._value;
        }

        public static QueryOption fromString(String str) {
            if ("useFilter".equals(str)) {
                return USE_FILTER;
            }
            if (SchedulerSupport.NONE.equals(str)) {
                return NONE;
            }
            if ("all".equals(str)) {
                return ALL;
            }
            return null;
        }
    }

    private LayerQuery(int i, QueryOption queryOption, String str, boolean z, boolean z2) {
        this._where = "";
        this._layerId = i;
        this._queryOption = queryOption;
        this._where = str;
        this._includeRelated = z;
        this._useGeometry = z2;
        this._queryOption = queryOption;
    }

    private LayerQuery(int i) {
        this._where = "";
        this._layerId = i;
    }

    public static LayerQuery createUsingFilter(int i, String str, boolean z) {
        return new LayerQuery(i, QueryOption.USE_FILTER, str, false, z);
    }

    public static LayerQuery createRelatedFeatures(int i) {
        return new LayerQuery(i, QueryOption.NONE, "", true, false);
    }

    public static LayerQuery createReturnAll(int i) {
        return new LayerQuery(i, QueryOption.ALL, "", false, false);
    }

    public static LayerQuery createReturnNone(int i) {
        return new LayerQuery(i, QueryOption.NONE, "", false, false);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void toJson(JsonGenerator jsonGenerator) throws JsonGenerationException, IOException {
        jsonGenerator.writeFieldName(new Integer(this._layerId).toString());
        jsonGenerator.writeStartObject();
        jsonGenerator.writeStringField("queryOption", this._queryOption.getValue());
        int i = AnonymousClass1.$SwitchMap$com$esri$core$tasks$geodatabase$LayerQuery$QueryOption[this._queryOption.ordinal()];
        if (i == 2) {
            jsonGenerator.writeBooleanField("includeRelated", this._includeRelated);
        } else if (i == 3) {
            jsonGenerator.writeBooleanField("useGeometry", this._useGeometry);
            jsonGenerator.writeStringField("where", this._where);
        }
        jsonGenerator.writeEndObject();
    }

    /* renamed from: com.esri.core.tasks.geodatabase.LayerQuery$1  reason: invalid class name */
    /* loaded from: classes.dex */
    static /* synthetic */ class AnonymousClass1 {
        static final /* synthetic */ int[] $SwitchMap$com$esri$core$tasks$geodatabase$LayerQuery$QueryOption;

        static {
            int[] iArr = new int[QueryOption.values().length];
            $SwitchMap$com$esri$core$tasks$geodatabase$LayerQuery$QueryOption = iArr;
            try {
                iArr[QueryOption.ALL.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                $SwitchMap$com$esri$core$tasks$geodatabase$LayerQuery$QueryOption[QueryOption.NONE.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                $SwitchMap$com$esri$core$tasks$geodatabase$LayerQuery$QueryOption[QueryOption.USE_FILTER.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
        }
    }

    public static LayerQuery fromJson(int i, JsonParser jsonParser) throws Exception {
        if (d.c(jsonParser)) {
            LayerQuery layerQuery = new LayerQuery(i);
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if (currentName.equals("queryOption")) {
                    layerQuery._queryOption = QueryOption.fromString(jsonParser.getText());
                } else if (currentName.equals("includeRelated")) {
                    layerQuery._includeRelated = jsonParser.getBooleanValue();
                } else if (currentName.equals("useGeometry")) {
                    layerQuery._useGeometry = jsonParser.getBooleanValue();
                } else if (currentName.equals("where")) {
                    layerQuery._where = jsonParser.getText();
                } else {
                    jsonParser.skipChildren();
                }
            }
            return layerQuery;
        }
        return null;
    }

    public int hashCode() {
        int i = ((((this._includeRelated ? 1231 : 1237) + 31) * 31) + this._layerId) * 31;
        QueryOption queryOption = this._queryOption;
        int hashCode = (((i + (queryOption == null ? 0 : queryOption.hashCode())) * 31) + (this._useGeometry ? 1231 : 1237)) * 31;
        String str = this._where;
        return hashCode + (str != null ? str.hashCode() : 0);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            LayerQuery layerQuery = (LayerQuery) obj;
            if (this._includeRelated == layerQuery._includeRelated && this._layerId == layerQuery._layerId && this._queryOption == layerQuery._queryOption && this._useGeometry == layerQuery._useGeometry) {
                String str = this._where;
                if (str == null) {
                    if (layerQuery._where != null) {
                        return false;
                    }
                } else if (!str.equals(layerQuery._where)) {
                    return false;
                }
                return true;
            }
            return false;
        }
        return false;
    }
}
